package com.ht.module.bus.controller;

import com.ht.util.JsonResult;
import com.ht.util.Pager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ht.module.bus.entity.TRoute;
import com.ht.module.bus.service.TRouteService;
import com.ht.util.*;
import javax.validation.Valid;


/**
 * <p>
 * 线路信息表，是使用线路沙盘功能规划的线路信息保存表 前端控制器
 * </p>
 *
 * @author hejialun
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/t-route")
public class TRouteController {

    
    @Autowired
    private TRouteService tRouteService;


    @ApiOperation("查询所有路线")
    @GetMapping("/findList")
    public JsonResult findList( TRoute en){
        return JsonResult.success(tRouteService.findList(en));
    }


	@ApiOperation("分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<TRoute> pager, TRoute en){
        return JsonResult.success(tRouteService.findPage(pager,en));
    }



	@ApiOperation("通过id查询")
    @GetMapping("/get-by-id/{id}")
    public JsonResult getById(@PathVariable(value = "id") String id){
        return JsonResult.success(tRouteService.getById(id));
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public JsonResult add(@RequestBody @Valid TRoute en){
	    CommMethod.beanCreate(en);
        tRouteService.save(en);
        return JsonResult.success();
    }

    @ApiOperation("通过id删除")
    @DeleteMapping("/delete-by-id/{id}")
    public JsonResult delete(@PathVariable(value = "id") String id){
        tRouteService.removeById(id);
        return JsonResult.success();
    }

    @ApiOperation("修改")
    @PutMapping("/update")
    public JsonResult updateById(@RequestBody @Valid TRoute en){
	    CommMethod.beanUpdate(en);
        tRouteService.updateById(en);
        return JsonResult.success();
    }

}
